﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net.Appender;
using log4net.Core;

namespace UPNP.Inspector
{
    public sealed class LogBoxAppender : AppenderSkeleton
    {
        public static LogBoxAppender Instance
        {
            get;
            private set;
        }

        private Queue<string> _msgs = new Queue<string>();

        public Queue<string> Messages
        {
            get { return _msgs; }
        }

        public LogBoxAppender()
        {
            Instance = this;
        }

        ~LogBoxAppender()
        {
            if (Instance == this)
                Instance = null;
        }

        protected override void Append(LoggingEvent loggingEvent)
        {
            _msgs.Enqueue(loggingEvent.RenderedMessage);
        }
    }
}
